import java.io.IOException;
import java.util.Scanner;

/**
 * @author 86157
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Student student = new Student();
        Dao dao = new Dao();
        System.out.println("学生数学练习系统");
        System.out.println("请输入你的id");
        boolean flag = true;
        boolean sign = true;
        while (flag){
            String id = sc.next();
                if (dao.judge(id)){
                    student.setId(id);
                    while (sign){
                        System.out.println("请选择使用的功能：1、2、3、4");
                        System.out.println("(1)开始测试");
                        System.out.println("(2)检查分数");
                        System.out.println("(3)历史成绩");
                        System.out.println("(4)退出");
                        int input = sc.nextInt();
                        switch (input){
                                case 1:
                                    try {
                                        dao.test(student);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                    System.out.println("学生成绩："+student.getScore());
                                    break;
                                case 2:
                                    System.out.println("问题|答案|正确答案");
                                    try {
                                        dao.check();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                    break;
                                case 3:
                                    try {
                                        dao.printAllData();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                    break;
                                case 4:
                                    sign = false;
                                    flag = false;
                                    break;
                                default:
                                    System.out.println("请输入正确的功能序号");
                                    break;
                            }
                        }
                    }else {
                        System.out.println("id有误");
                        flag = false;
                    }
                }
            }

}
